#import "SEGSelectauthorityroleManager.h"

#if __has_include(<Commom/SEGModel.h>)
#import <Commom/SEGModel.h>
#else
#import "SEGModel.h"
#endif
#if __has_include(<Commom/SEGHTTPBusinessManager.h>)
#import <Commom/SEGHTTPBusinessManager.h>
#else
#import "SEGHTTPBusinessManager.h"
#endif

static id _SelectAuthorityRoleManager;
static dispatch_once_t onceToken;

@implementation SEGSelectauthorityroleManager
#pragma mark - SINGLE----BEGIN----
+(instancetype)sharedManager{
    dispatch_once(&onceToken, ^{
        _SelectAuthorityRoleManager = [[self alloc] init];
    });
    return _SelectAuthorityRoleManager;
}

+(void)destroyResource{
    onceToken = 0;
    _SelectAuthorityRoleManager = nil;
}

#pragma mark - SINGLE----END----

#pragma mark - HTTP----BEGIN----
-(void)requestSelectauthorityroleWithCommunityid:(NSString*)communityId enterpriseId:(NSString*)enterpriseId organId:(NSString*)organId propId:(NSString*)propId finished:(void(^)(BOOL isSuccessed,id result,NSString* codeType,NSString* errorMessage))finished{
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
//    [params setValue:communityId forKey:@"communityId"];
    [params setValue:enterpriseId forKey:@"enterpriseId"];
    [params setValue:propId forKey:@"propId"];
    [params setValue:organId forKey:@"organId"];
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/enterprise-app/role/selectAuthorityRole.json",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:params completed:^(BOOL isSuccessed, id result, NSString *codeType, NSError *error) {
        if (!isSuccessed) {
            finished(isSuccessed,nil,codeType,error.localizedDescription);
            return;
        }
        
        self.SelectAuthorityRole = [SEGSelectauthorityroleModel yy_modelWithDictionary:result];
        finished(isSuccessed,result,codeType,error.localizedDescription);
        return;
    }];
}

/// 根据受众类型查询受众信息
/// @author Sam
/// @see http://192.168.1.11:9090/html/web/controller/share/share.html#5fea976b5eb237b1ac620499
-(void)requestSelectbyaudiencesgroupcodeFinished:(void(^)(BOOL isSuccessed,id result,NSString* codeType,NSString* errorMessage))finished{
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setValue:@"enterpriseUser" forKey:@"audiencesGroupCode"];
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/terrace-service-app/terraceServiceAudiences/selectByAudiencesGroupCode",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:params completed:^(BOOL isSuccessed, id result, NSString *codeType, NSError *error) {
        if (!isSuccessed) {
            finished(isSuccessed,nil,codeType,error.localizedDescription);
            return;
        }
        
        self.SelectByAudiencesGroupCode = [SEGSelectbyaudiencesgroupcodeModel yy_modelWithDictionary:result];
        finished(isSuccessed,result,codeType,error.localizedDescription);
        return;
    }];
}
#pragma mark - HTTP----END----

#pragma mark - GETTER----BEGIN----
-(SEGSelectauthorityroleModel *)SelectAuthorityRole{
    if (!_SelectAuthorityRole) {
        _SelectAuthorityRole = [[SEGSelectauthorityroleModel alloc]init];
    }
    return _SelectAuthorityRole;
}
-(SEGSelectbyaudiencesgroupcodeModel *)SelectByAudiencesGroupCode{
if (!_SelectByAudiencesGroupCode) {
_SelectByAudiencesGroupCode = [[SEGSelectbyaudiencesgroupcodeModel alloc]init];
}
return _SelectByAudiencesGroupCode;
}
#pragma mark - GETTER----END----
@end

